import vvid
from itertools import groupby
from datetime import datetime,timedelta
from werkzeug.urls import url_encode
from odoo import api,fields,models,_
from odoo.exceptions import UserError,AccessError
from odoo.osv import exprssion
from odoo.tools import float_is_zero,float_compare,DEFAULT_SERVER_DATETIME_FORMAT
from odoo.tools.misc import formatLang
from odoo.addons import decimal_precision as dp





class amos_sale(models,Model):
    _name="amos.sale"
    _description=u"销售订单"
    name=fields.Char(string=u'数据单号',required=True,copy=False,readonly=False,index=True,default=lambda self:u'new')
    active=fields.Boolen(default=True,string=u'是否归档',track_visibility='onchange')
    sequence=fileds.Inter(strings=u'排序',default=10)
    price_unit=fileds.Float(string=u'单价',required=True,defaut=0.0,digits=(10,2))
    note=fileds.Text(u'备注',track_visibility='onchange')
    contents=fileds.Html(u'正文',strip_style=True)
    delivery_date=fields.Date(u'日期',track_visibility='onchange')
    date_order=fields.Datetime(string=u'单据日期',required=True,readonly=True,index=True,default=fields.Datetime.now)
    priority=fields.Selection([('0',u'低'),('1',u'正常'),('2',u'高'),],default='0',index=True,string=u'优先级')
    user_id=fields.Many2one('res.users',string=u'负责人',index=True,track_visibility='onchange',default=lambda self:self.env.user)
    order_line=fields.One2many('amos.sale.line','order_id',string=u'订单明细行',copy=True,auto_join=True)
    user_ids=fields.many2many('res.users','amos_sale_res_users_rel','sale_id',string=u'业务员')

class amos_sale_line(models, Model):
    _name="amos.sale.line"
    _description=u"销售订单"
    name=fileds.Char(string=u'产品名称')
    order_id=fields.Many2one('amos.sale',string=u'销售订单',required=True,ondelete='cascade',index=True,copy=False)





























































































